package com.csdj.t309.utils;

import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;

import java.util.Calendar;

public class DateUtil {

    public static long getRemainderSecond(){
        //当前秒数
        long curInMillis = System.currentTimeMillis();
        //需要当天晚上24点的秒数
        Calendar calendar = Calendar.getInstance();
        //日期添加一天
        calendar.add(Calendar.DAY_OF_YEAR,1);
        //小时数设置为0
        calendar.set(Calendar.HOUR_OF_DAY,0);
        //分钟数设置0
        calendar.set(Calendar.MINUTE,0);
        //秒数设置0
        calendar.set(Calendar.SECOND,0);
        //毫秒数设置0
        calendar.set(Calendar.MILLISECOND,0);
        //晚上24点的时间戳
        long timeInMillis = calendar.getTimeInMillis();
        //两个时间相减
        return (timeInMillis-curInMillis)/1000;
    }

    public static void main(String[] args) {
        System.out.println(getRemainderSecond());
    }
}


